package com.sleep.blog.controller;

import com.sleep.blog.service.TagService;
import com.sleep.blog.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Sleep-6000
 * @date 2021/9/10
 */
@RestController
@RequestMapping("tags")
public class TagsController {

    @Autowired
    private TagService tagService;

    /**
     * 查询最热标签
     * @return 查询结果
     */
    @GetMapping("hot")
    public Result hot() {
        int limit = 6;
        return tagService.hots(limit);
    }

    /**
     * 查询所有标签
     * @return 查询结果
     */
    @GetMapping
    public Result findAll() {
        return tagService.findAll();
    }

    /**
     * 查询所有标签详情
     * @return 查询结果
     */
    @GetMapping("detail")
    public Result tagsDetail() {
        return tagService.findAllDetail();
    }

    /**
     * 根据 id 查询标签详情
     * @param id id
     * @return 查询结果
     */
    @GetMapping("detail/{id}")
    public Result tagDetailById(@PathVariable("id") Long id) {
        return tagService.tagDetailById(id);
    }
}
